<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <script>
      /*
        await 到底在等什么
        1. 等待promise执行resolve()
        2. await后续代码都是微任务异步代码
              */
      const p1 = new Promise((resolve, reject) => {
        setTimeout(() => {
          resolve(100);
        }, 3000);
      });
      async function fn() {
        console.log(1000);
        const r = await p1;
        console.log(r);
        console.log(1);
        console.log(2);
        console.log(3);
      }
      fn();
      console.log(2000);
    </script>
  </body>
</html>
